<?
include('../controller/handler.php');

$hd = new Handler();
$base_url = $hd->getBaseURL();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<?
	/****************
	 * HEAD MODULE
	 ***************/
	include('../module/head.inc.php');
	?>
	<link rel="stylesheet" href="<?echo $base_url;?>style/style_api.css" type="text/css" media="screen" charset="utf-8" />
	<script src="<?echo $base_url;?>js/api.js" type="text/javascript" charset="utf-8"></script>

	<title><?echo $hd->getTitle();?> - Docs</title>
	
</head>

<body>
<?
/****************
 * HEADER MODULE
 ***************/
include('../module/header.inc.php');
?>
<div id="stripe"></div>

<div id="main">
<?
if(isset($_GET['class'])) {
	$class_selected = $_GET['class'];

	$xml = simplexml_load_file("../conf/classes.xml");
	$class = NULL;

	switch($class_selected) {
		case 'User':
			$class = $xml->user;
			break;
		case 'Tag':
			$class = $xml->tag;
			break;
		case 'Handler': 
			$class = $xml->handler;
			break;
		case 'Twitter':
			$class = $xml->twitter;
			break;
		case 'Twitwords':
			$class = $xml->twitwords;
			break;
		default: 
			$class = $xml->error;
			break;
	}

	$attributes = $class->attribute;
	$methods = $class->method;

	$i = 0;
	?>
	<h2>Attributes</h2>
	<table>
	<?
	foreach($attributes as $attr) {
		$class = ($i%2==0)? 'even' : 'odd';
		$i++;
	?>
		<tr class="<?echo $class;?>">
			<td class="attribute"><?echo $attr->name;?></td> <td class="description"><?echo $attr->description;?></td>
		</tr>
	<?
	}
	?>
	</table>
	
	<h2>Methods</h2>
	<?

	$i = 1;
	foreach($methods as $method) {
		$class = ($i%2==0)? 'even' : 'odd';
		$i++;
	?>
		<div class="method <?echo $class;?>">
			<p class="interface"><?echo $method->type;?> <?echo $method->return;?> <?echo $method->interface;?></p>
			<p class="description"><?echo $method->description;?></p>
		</div>
	<?
	}
} else {
?>
<h1>Select a class</h1>
<div class="classes-list">
	Class::Scaffold { 
		<ul><li><a href="<?echo $base_url;?>docs/User">User</a></li>
			<li><a href="<?echo $base_url;?>docs/Tag">Tag</a></li>
		</ul>
	}
	<br />
	Class::Controller { 
		<ul><li><a href="<?echo $base_url;?>docs/Handler">Handler</a></li>
			<li><a href="<?echo $base_url;?>docs/Twitter">Twitter</a></li>
			<li><a href="<?echo $base_url;?>docs/Twitwords">Twitwords</a></li>
		</ul>
	}
</div>
<?
}
?>
<div id="credits"><?echo $hd->getCredits();?></div>
</div>

<div id="footer">
	<div id="nav">
		{ Scaffold <a href="<?echo $base_url;?>docs/User">User</a> ~ 
		<a href="<?echo $base_url;?>docs/Tag">Tag</a> }
		{ Controller <a href="<?echo $base_url;?>docs/Handler">Handler</a> ~
		<a href="<?echo $base_url;?>docs/Twitter">Twitter</a> ~
		<a href="<?echo $base_url;?>docs/Twitwords">Twitwords</a> }
	</div>
	<?
	/****************
	 * FOOTER MODULE
	 ***************/
	include('../module/footer.inc.php');
	?>
</div>

<?include('../module/analytics.inc.php');?>
</body>
</html>
